package com.ruoyi.web.controller.yanglao;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.yanglao.YlRetirementOrganize;
import com.ruoyi.system.service.yanglao.IYlRetirementOrganizeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 养老机构Controller
 * 
 * @author ruoyi
 * @date 2024-06-14
 */
@Api("养老机构")
@RestController
@RequestMapping("/yanglao/retirementOrganize")
public class YlRetirementOrganizeController extends BaseController
{
    @Autowired
    private IYlRetirementOrganizeService ylRetirementOrganizeService;

    /**
     * 查询养老机构列表
     */
    @ApiOperation("查询养老机构列表")
    @PreAuthorize("@ss.hasPermi('yanglao:retirementOrganize:list')")
    @GetMapping("/list")
    public TableDataInfo list(YlRetirementOrganize ylRetirementOrganize)
    {
        startPage();
        List<YlRetirementOrganize> list = ylRetirementOrganizeService.selectYlRetirementOrganizeList(ylRetirementOrganize);
        return getDataTable(list);
    }

    /**
     * 导出养老机构列表
     */
    @ApiOperation("导出养老机构列表")
    @PreAuthorize("@ss.hasPermi('yanglao:retirementOrganize:export')")
    @Log(title = "养老机构", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YlRetirementOrganize ylRetirementOrganize)
    {
        List<YlRetirementOrganize> list = ylRetirementOrganizeService.selectYlRetirementOrganizeList(ylRetirementOrganize);
        ExcelUtil<YlRetirementOrganize> util = new ExcelUtil<YlRetirementOrganize>(YlRetirementOrganize.class);
        util.exportExcel(response, list, "养老机构数据");
    }

    /**
     * 获取养老机构详细信息
     */
    @ApiOperation("获取养老机构详细信息")
    @PreAuthorize("@ss.hasPermi('yanglao:retirementOrganize:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ylRetirementOrganizeService.selectYlRetirementOrganizeById(id));
    }

    /**
     * 新增养老机构
     */
    @ApiOperation("新增养老机构")
    @PreAuthorize("@ss.hasPermi('yanglao:retirementOrganize:add')")
    @Log(title = "养老机构", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YlRetirementOrganize ylRetirementOrganize)
    {
        return toAjax(ylRetirementOrganizeService.insertYlRetirementOrganize(ylRetirementOrganize));
    }

    /**
     * 修改养老机构
     */
    @ApiOperation("修改养老机构")
    @PreAuthorize("@ss.hasPermi('yanglao:retirementOrganize:edit')")
    @Log(title = "养老机构", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YlRetirementOrganize ylRetirementOrganize)
    {
        return toAjax(ylRetirementOrganizeService.updateYlRetirementOrganize(ylRetirementOrganize));
    }

    /**
     * 删除养老机构
     */
    @ApiOperation("删除养老机构")
    @PreAuthorize("@ss.hasPermi('yanglao:retirementOrganize:remove')")
    @Log(title = "养老机构", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ylRetirementOrganizeService.deleteYlRetirementOrganizeByIds(ids));
    }
}
